﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BFlatCompile.Nodes
{
	internal class Consolidator
	{
		private List<ICodeContainer> list;

		public Consolidator()
		{
			this.list = new List<ICodeContainer>();
		}

		public Consolidator Add(Expression expr)
		{
			if (expr != null)
			{
				this.list.Add(expr);
			}
			return this;
		}

		public Consolidator Add(Executable exec)
		{
			if (exec != null)
			{
				this.list.Add(exec);
			}
			return this;
		}

		public Consolidator Add(IList<Expression> expressions)
		{
			if (expressions != null)
			{
				this.list.AddRange(expressions);
			}
			return this;
		}

		public Consolidator Add(IList<Executable> executables)
		{
			if (executables != null)
			{
				this.list.AddRange(executables);
			}
			return this;
		}

		public IList<ICodeContainer> List()
		{
			return this.list;
		}
	}
}
